import React, { Component } from 'react'
import img from '../../assets/img/123.png'
import {connect} from 'react-redux'
import {changeMsg} from '../../store/actions/test'
// 把state中的数据，变成当成组件的props
function mapStateToProps(state){
    return {
        msg:state.msg,
        
    }
}
// 把actions中方法，放在当前组件的props
function mapActionToProps(dispatch){
    return {
        changeHandle: (payload)=>dispatch(changeMsg(payload)),  // { type:1, payload}
      }

}
 class Home extends Component {
    constructor(props){
        // console.log("333",props);
        super(props)
        this.state= {

        }
    }
    componentDidMount() {
        // 调接口
        
      }
    clickHandle(){
        this.props.changeHandle('202020')
    }
    createCnodeList(){
        // console.log('222',this.props.cnodelist);
        return this.props.cnodelist.map(ele=>(
            <div key={ele.id}>{ele.title}</div>
        ))
    }
    render() {
        return (
            <div>
                <h1>这里是首页管理</h1>
                <img src={img} alt="123" />
                <button onClick={this.clickHandle.bind(this)}>点击</button>
                <hr/>
            </div>
        )
    }
}
export default connect(mapStateToProps,mapActionToProps)(Home)

